﻿using Microsoft.Extensions.Primitives;
using System.Collections.Generic;
using System.Text;
using XCore.Domain.Enums;
using XCore.Extensions;
using XCore.Helper;

namespace SaaS.Core.Helper
{
    public class HttpClientHeler
    {
        /// <summary>
        /// 推送
        /// </summary>
        /// <param name="message">消息</param>
        /// <returns></returns>
        public static string Hub(string message)
        {
            return NetHelper.Post(CoreSetting.HubServer.Url, new Dictionary<string, StringValues>() { { "Message", message } }, CoreSetting.HubServer.Header);
        }
        public static string Hub<T>(T value)
        {
            return NetHelper.Post(CoreSetting.HubServer.Url, ContentType.Form, Encoding.UTF8.GetBytes(value.ToJson()), CoreSetting.HubServer.Header);
        }
        public static string Util(string url, IDictionary<string, StringValues> data)
        {
            return NetHelper.Post(CoreSetting.UtilServer.Url + url, data, CoreSetting.UtilServer.Header);
        }
        public static string Util(IDictionary<string, StringValues> data)
        {
            return NetHelper.Post(CoreSetting.UtilServer.Url, data, CoreSetting.UtilServer.Header);
        }
    }
}
